package com.xingchi.tornado.log.config;

import com.xingchi.tornado.log.aspect.BizLogAspect;
import com.xingchi.tornado.log.aspect.WebLogAspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * web配置
 *
 * @author xiaoya
 * @date 2024/9/26 15:04
 */
@Configuration
@EnableConfigurationProperties(WebProperties.class)
public class TornadoWebConfiguration {

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(value = "xingchi.tornado.web.log-enable", havingValue = "true")
    public WebLogAspect webLogAspect(WebProperties webProperties) {
        return new WebLogAspect(webProperties.getSlowLogInterval());
    }

    @Bean
    @ConditionalOnMissingBean
    public BizLogAspect bizLogAspect() {
        return new BizLogAspect();
    }

}
